package mest.service.cxj.impl;


import mest.Dto.cxj.WorkFileDto;
import mest.dao.cxj.WorkFileDao;
import mest.entity.work_file;
import mest.service.cxj.WorkFileService;
import mest.util.ResultObj;
import mest.util.mestUtil;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class WorkFileServiceImpl implements WorkFileService {

    @Resource
    private WorkFileDao workFileDao;


    @Override
    public List<WorkFileDto> selectAllWorkFile(Integer page, Integer limit, String workName, String theirDb) {
        return workFileDao.selectAllWorkFile((page - 1) * limit, limit, workName, theirDb);
    }

    @Override
    public Integer selectCountWorkFile(String workName, String theirDb) {
        return workFileDao.selectCountWorkFile(workName, theirDb);
    }

    @Override
    public boolean insertWorkFile(work_file workFile, String theirDb) {
        boolean flag = false;
        int num = workFileDao.insertWorkFile(workFile,theirDb);
        if (num > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public boolean deleteWorkFile(Integer id, String theirDb) {
        boolean flag = false;
        int num = workFileDao.deleteWorkFile(id, theirDb);
        if (num > 0) {
            flag = true;
        }
        return flag;
    }

	@Override
	public ResultObj update(Map<String, Object> map) {
		// TODO Auto-generated method stub
		if ( mestUtil.isDouble(map.get("workPrice")+"") ) {
			workFileDao.update(map);
			return ResultObj.createSuccessMsg(ResultObj.SUCCESS);
		} else {
			return ResultObj.createErrorMsg("工价只能是数字");
		}
		
	}


}

